package com.system.bill.bean;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.persistence.*;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @className: Bill
 * @description: 账单实体类
 * @author: Li Chuanwei
 * @date: 2023/11/12 13:49
 * @Company: Copyright [日期] by [作者或个人]
 **/
@Data
@Entity
@JsonIgnoreProperties({"hibernateLazyInitializer","handler","fieldHandler"})
public class Bill {

    /**
     * 自增长ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer billId;

    /**
     * 预约单号
     */
    private String billNumber;


    /**
     * 关联的患者ID号
     */
    private Integer patientId;

    /**
     * 账单价格
     */
    private BigDecimal price;

    /**
     * 状态:0不可用,1可用
     */
    @Column(columnDefinition = "integer default 1")
    private Integer state = 1;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    private LocalDateTime updateTime;

    @PrePersist
    protected void onCreate() {
        createTime = LocalDateTime.now();
        updateTime = LocalDateTime.now();
    }

    @PreUpdate
    protected void onUpdate() {
        updateTime = LocalDateTime.now();
    }
}

